-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PRMT-4568 - ehr-repository - Remove PostgreSQL Implementation and Sequelize Dependencies #73
Conversation
…tring to address a mac specific problem
…for local testing
…odb integration test
… separating model and repository layer
…termine latest record
…js to new dynamodb-based implementation
…. Store current progress
…ark and ticket number to old postgres related codes
package.json
Outdated
@@ -18,10 +18,7 @@ | |||
"build": "babel src -d build --ignore '**/*.test.js' --ignore '**/__mocks__/*' && cp src/*.json build", | |||
"start": "node build/server.js", | |||
"start:local": "npm run db:migrate ; babel-node -r dotenv/config src/server.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this line npm run db:migrate
need to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Just removed this
terraform-db-roles/dynamodb.tf
Outdated
data "aws_iam_policy_document" "ehr-transfer-tracker-db-access" { | ||
statement { | ||
actions = [ | ||
"dynamodb:GetItem", | ||
"dynamodb:PutItem", | ||
"dynamodb:UpdateItem", | ||
"dynamodb:Query" | ||
] | ||
resources = [ | ||
"arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "ehr-transfer-tracker-db-access" { | ||
name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | ||
policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | ||
} | ||
|
||
# Grant ECS Task permissions to access the transfer tracker db | ||
resource "aws_iam_role_policy_attachment" "dynamodb_application_user_policy_attach" { | ||
role = "${var.environment}-${var.component_name}-EcsTaskRole" | ||
policy_arn = aws_iam_policy.ehr-transfer-tracker-db-access.arn | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice sometimes you've named the resource identifiers with hyphens and sometimes with underscores. Although there's no strict guideline on how to name identifiers, generally underscores are preferred, which is how we've been naming new Terraform code we've been writing.
data "aws_iam_policy_document" "ehr-transfer-tracker-db-access" { | |
statement { | |
actions = [ | |
"dynamodb:GetItem", | |
"dynamodb:PutItem", | |
"dynamodb:UpdateItem", | |
"dynamodb:Query" | |
] | |
resources = [ | |
"arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | |
] | |
} | |
} | |
resource "aws_iam_policy" "ehr-transfer-tracker-db-access" { | |
name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | |
policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | |
} | |
# Grant ECS Task permissions to access the transfer tracker db | |
resource "aws_iam_role_policy_attachment" "dynamodb_application_user_policy_attach" { | |
role = "${var.environment}-${var.component_name}-EcsTaskRole" | |
policy_arn = aws_iam_policy.ehr-transfer-tracker-db-access.arn | |
} | |
data "aws_iam_policy_document" "ehr_transfer_tracker_db_access" { | |
statement { | |
actions = [ | |
"dynamodb:GetItem", | |
"dynamodb:PutItem", | |
"dynamodb:UpdateItem", | |
"dynamodb:Query" | |
] | |
resources = [ | |
"arn:aws:dynamodb:${var.region}:${data.aws_caller_identity.current.account_id}:table/${var.environment}-ehr-transfer-tracker" | |
] | |
} | |
} | |
resource "aws_iam_policy" "ehr_transfer_tracker_db_access" { | |
name = "${var.environment}-${var.component_name}-transfer-tracker-db-access" | |
policy = data.aws_iam_policy_document.ehr-transfer-tracker-db-access.json | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this! Just changed the hyphens to underscore
|
||
export const getDynamodbClient = () => { | ||
const clientConfig = { | ||
region: process.env.AWS_DEFAULT_REGION ?? 'eu-west-2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comma at the end needed?
// TODO: remove this duplicated `conversationIdFromEhrIn` field, | ||
// after updating ehr-out to use the field name "inboundConversationId" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please put the Ticket number on this TODO, so we know what it refers to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Just added ticket number to TODO
src/errors/errors.js
Outdated
|
||
export const errorMessages = { | ||
HealthRecordNotFound: 'No complete health record was found with given criteria', | ||
MessageNotFound: 'There were no undeleted messages associated with conversation id', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be better instead of "undeleted", maybe term it "There are no existing messages associated with conversation id" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changed to no existing messages
… from `CORE#{messageId}` to just `CORE`
throw new Error('recordType has to be either Core or Fragment'); | ||
} | ||
if (!inboundConversationId && !inboundMessageId) { | ||
throw new Error('must be called with both conversationId and inboundMessageId'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you replace "conversationId" with "inboundConversationId" for clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated the error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed. Once you have addressed last comments, let me know so I can approve. Good job on this, I'm impressed you got all this done in a week!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well Done!
No description provided.